package de.draufi.xml;

import java.io.File;
import java.io.IOException;

import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.JDOMException;
import org.jdom2.input.SAXBuilder;
import org.jdom2.input.sax.XMLReaders;

import de.draufi.logging.myLogger;

public class KMLReader {

	private Document doc = null;
	
	@SuppressWarnings("unused")
	private Element root = null;
	@SuppressWarnings("unused")
	private Element track = null;
	
	public KMLReader(File f) {
		try {
			SAXBuilder sb = new SAXBuilder(XMLReaders.NONVALIDATING);
			doc = sb.build(f);
		} catch (JDOMException e) {
			myLogger.getLog(this.getClass().getName()).severe(e.getMessage());
		} catch (IOException e) {
			myLogger.getLog(this.getClass().getName()).severe(e.getMessage());
		}
		if (doc == null){
			myLogger.getLog(this.getClass().getName()).warning("Error reading SAX-Document: " + f);
		} else {
			myLogger.getLog(this.getClass().getName()).info("using " + f);
			root = doc.getRootElement( );
			
			//TODO weiteres Implementieren der kml-Dateien
			
		}
	}

}
